package com.example.demo.controller;


import com.alibaba.fastjson.JSON;
import com.example.demo.dto.PageConfigItemBatchDto;
import com.example.demo.dto.PageConfigItemDto;
import com.example.demo.service.PageConfigItemService;
import com.example.demo.utils.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/page-config-item")
@RequiredArgsConstructor
public class PageConfigItemController {


    @Autowired
    private PageConfigItemService itemService;

    /**
     * 文字单条 + 图片/视频多条
     */
    @PostMapping("/batch")
    public Result<Void> batch(@RequestBody PageConfigItemDto dto) {
        System.out.println("接收到保存请求: " + JSON.toJSONString(dto, true));
        itemService.batchSaveItems(dto);
        return Result.success(null);
    }

}
